package lifecraft;

import java.awt.Font;
import java.io.InputStream;

import org.newdawn.slick.Color;
import org.newdawn.slick.*;
import org.newdawn.slick.util.ResourceLoader;

final class FontBase{
    private static FontBase BaseF = new FontBase();
    
    private FontBase(){
    }
    
    public static FontBase get(){
        return BaseF;
    }
    public FontType f0; 
    public FontType f1;
    public FontType f2;
    
    public void init() {
        
        System.out.println("Inicjalizacja Czcionek");
        f0 = new FontType(); f0.init("fonts/Alan Den.ttf",24);
        f1 = new FontType(); f1.init("fonts/Alan Den.ttf",40);
        f2 = new FontType(); f2.init("fonts/Alan Den.ttf",45);
    }

}

public class FontType {
    
    private TrueTypeFont font_FT;
    public float size_FT = 24; 
    
    private boolean antiAlias = true;
    private Font awtFont;
  
    public void init() {
        init(24f);
    }
    
    public void init(float size) {
    // load a default java font
    size_FT = size;
    awtFont = new Font("Ariel", Font.PLAIN, (int) size_FT);
    font_FT = new TrueTypeFont(awtFont, antiAlias); 
    }
   
    public void init(String adres) {		
        init(adres, 24f);
    }  
    public void init(String adres, float size) {		
    size_FT = size;
    // load font from file
    try {
	InputStream inputStream	= ResourceLoader.getResourceAsStream(adres);
			
	awtFont = Font.createFont(Font.TRUETYPE_FONT, inputStream);
	awtFont = awtFont.deriveFont(size_FT); // set font size
	font_FT = new TrueTypeFont(awtFont, antiAlias);
			
	} catch (Exception e) {
	e.printStackTrace();
	}       
    }
    /**
     * Game loop render
     */
    public void write(int x_FT, int y_FT, String text, Color color){
        //Color.white.bind();
        
        font_FT.drawString(x_FT, y_FT, text, color);
    }
}
